<template>
	<view class="main">
		<view class="head">
			<view class="head-info">
				<image src="http://images.linglinggong.net/icon2/g.png" mode="aspectFill"></image>
				<text>您的支付已经完成！</text>
			</view>
		</view>
		<view class="content">
			<view class="trangle"></view>
			<view class="shengxiao">
				<view class="shengxiao-info" v-if="cardUserType!=0">
					<text>尊享{{isType==0?levelName:cardName+'加油包'}}生效中</text>
					<text>有效期至{{cardtime.split(' ')[0].split('-').join('.')}}</text>
				</view>
			</view>
			<view v-if="isFirstBuy" class="hongbao" @click="openPage('/pages/app-employer/my-coupon/my-coupon')">
				<image src="http://images.linglinggong.net/icon3/youhui123rewdsf.png" mode="aspectFill"></image>
				<text>100元</text>
				<text>优惠券已到账~</text>
				<image src="http://images.linglinggong.net/finishInvite-jt.png" mode="aspectFill"></image>
			</view>
			<view class="fabu-button" @click="openPage('/pages/app-employer/send-job/send-job')">发布零工</view>
		</view>
		<kefu v-if="isShowKefu" @closePage="closePage()"></kefu>
	</view>
</template>
<script>
	import {
		getUserInfo
	} from '@/libs/unit.js'
	import kefu from '../../components/xjbg/kefu.vue'
	export default {
		data() {
			return {
				isFirstBuy: false,
				isShowKefu: false,
				cardUserType: 0,
				cardtime: '',
				cardName: '',
				isType: 0,
				levelName: '',
			}
		},
		components: {
			kefu,
		},
		methods: {
			pageInit() {
				getUserInfo().then(v => {
					this.cardUserType = v.cardUserType
					this.cardtime = v.cardtime
					this.cardName = this.cardUserType == 1 ? '月卡' : this.cardUserType == 2 ? '半年卡' : this
						.cardUserType == 3 ? '年卡' : this.cardUserType == 0 ? '未获得' : '体验卡'
				})
			},
			openPage(url) {
				//#ifdef MP-ALIPAY 
				uni.reLaunch({
					url: url
				})
				// #endif
				//#ifdef MP-WEIXIN|| MP-TOUTIAO
				uni.navigateTo({
					url: url
				})
				// #endif
			},
			closePage() {
				this.isShowKefu = false
			},
		},
		onLoad(value) {
			this.isFirstBuy = value.isFirstBuy == 'true' ? true : false
			this.isType = parseInt(value.type)
			try {
				this.levelName = value.levelName
			} catch (e) {
				//TODO handle the exception
			}
			this.pageInit()
		},
		onNavigationBarButtonTap() {
			this.isShowKefu = true
		},
		onBackPress() {
			uni.redirectTo({
				url: '/pages/bossMonthCard/straightCard'
			})
			return true
		},
	}
</script>
<style lang="less" scoped>
	.head {
		width: 750rpx;
		height: 240rpx;
		background: #FCC928;
	}

	.content {
		width: 750rpx;
		margin-top: -20rpx;
		background: #FFFFFF;
		border-radius: 25rpx 25rpx 0 0;
		height: calc(100vh - 320rpx + 44px);
	}

	.trangle {
		width: 0px;
		height: 0px;
		border: 20rpx solid #FCC928;
		border-bottom-color: transparent;
		border-left-color: transparent;
		border-right-color: transparent;
		margin: 0 auto;
	}

	.shengxiao {
		width: 690rpx;
		height: 128rpx;
		// margin: 0 auto;
		margin: 78rpx auto 0 auto;
		border-radius: 20px;
		background-image: url(http://images.linglinggong.net/icon3/fdewrdgtgy6454.png);
		background-size: cover;
	}

	.shengxiao-info {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		position: relative;
		top: 50%;
		transform: translateY(-50%);

		&>text:nth-child(1) {
			font-size: 32rpx;
			font-weight: bold;
			color: #FFFFFF;
			line-height: 45rpx;
		}

		&>text:nth-child(2) {
			font-size: 24rpx;
			font-weight: 400;
			color: #FFFFFF;
			line-height: 45rpx;
		}
	}

	.hongbao {
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top: 52rpx;

		&>* {
			margin-left: 8rpx;
		}

		&>image:nth-child(1) {
			width: 28rpx;
			height: 28rpx;
		}

		&>text:nth-child(2) {
			font-size: 28rpx;
			font-weight: bold;
			color: #FE4B28;
			line-height: 45rpx;
		}

		&>text:nth-child(3) {
			font-size: 28rpx;
			font-weight: 500;
			color: #402110;
			line-height: 45rpx;
		}

		&>image:nth-child(4) {
			width: 12rpx;
			height: 22rpx;
		}
	}

	.mask {
		width: 100vw;
		height: 100vh;
		background-color: rgba(0, 0, 0, .5);
		position: fixed;
		top: 0;
		left: 0;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.alert_model {
		width: 550rpx;
		height: 306rpx;
		background: #FFFFFF;
		border-radius: 12rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		align-items: center;
	}

	.alert_model-title {
		font-size: 36rpx;
		font-weight: bold;
		color: #000000;
		margin-top: 60rpx;
	}

	.alert_model-content {
		font-size: 32rpx;
		font-weight: 500;
		color: #787878;
		flex: 1;
		margin-top: 40rpx;
	}

	.alert_model-button {
		height: 80rpx;
		border-top: 1rpx solid #BDBDBD;
		display: flex;
		justify-content: space-between;
	}

	.alert_model-button-quxiao {
		width: 274rpx;
		height: 80rpx;
		border-right: 1rpx solid #BDBDBD;
		font-size: 32rpx;
		font-weight: 500;
		color: #787878;
		line-height: 80rpx;
		text-align: center;
	}

	.alert_model-button-queding {
		width: 275rpx;
		height: 80rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #4E9800;
		line-height: 80rpx;
		text-align: center;
	}

	.fabu-button {
		margin: 72rpx auto 0 auto;
		width: 690rpx;
		height: 88rpx;
		background: #FCC928;
		border-radius: 44rpx;
		font-size: 32rpx;
		font-weight: bold;
		color: #402110;
		line-height: 88rpx;
		text-align: center;
	}

	.head-info {
		padding-top: 48rpx;
		display: flex;
		justify-content: center;
		align-items: center;

		&>image {
			width: 48rpx;
			height: 48rpx;
		}

		&>text {
			margin-left: 18rpx;
			font-size: 32rpx;
			font-weight: 500;
			color: #402110;
			line-height: 45rpx;
		}
	}
</style>